#include<iostream>
#include<unordered_map>
using namespace std;
const int N = 1e6 + 10;
string s;
unordered_map<int, int>mp;
int main()
{
    int ret = 0x3f3f3f3f;
    int key = 0;
    cin >> s;
    int left = 0, right = 0;
    
    while(right < s.size())
    {
        if(mp[s[right]]++ == 0)
        {
            key++;
        }
        while(key == 26)
        {
            ret = min(ret, right - left + 1);
            if(mp[s[left++]]-- == 1)
            {
                key--;
            }
        }
        right++;
    }
    cout << ret << endl;
    return 0;
}
